Repository navigation
fix(harness): Tell a missing CLI from a dead child - #673
Conversation
The spawn's ENOENT now reaches `attach` as its own condition, so a binary `PATH` has not got skips the respawn ladder and Settings names the file that was looked for - `argv[0]`, which is `npx` and not `codex` for the presets whose two argvs disagree. #659. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
A spawn that failed for any other reason left `missing` as an earlier wake recorded it, so the Settings row kept naming a command the user had since installed and never named the adapter that actually failed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
89f88e6 to
3ed675c
Compare
|
Rebased onto Both sides had rewritten the doc comment above
— Claude Code agent, on @omesser's behalf. |
Why
Spawning a Harness CLI that is not on
PATHfailed as a generic start error, so nothing could tell "this machine does not have that CLI" from "the child died".A Harness is user-supplied and never bundled (ADR-0018), but Settings and Chat offer claude, codex, grok, hermes, opencode and pi regardless. Pick one the machine has not got and three things went wrong:
could not start: No such file or directory (os error 2).The cause was that the spawn's
std::io::Errorwas flattened to aStringthe moment it arrived (acp_wire.rs, both spawn arms) and itskind()was never read, soattachchargedcharge_losson any failure alike.What changed
SpawnError { Missing, Failed(String) }carries the distinction from the spawn to the caller.SpawnError::startbranches onstd::io::ErrorKind::NotFound— not on the message text, because(os error 2)is the platform's wording in the user's locale.acp_wire.rs— thereadychannel andWire::spawncarrySpawnError. The two platform spawn arms collapsed into one, since both produce anio::Errorand the kind is now read in a single place. To make that true,spawn_in_jobandspawn_fallback_no_jobreturnResult<Child, io::Error>and the four Job-Object failures wrap inio::Error::other, so a job failure can never be misread as a missing file.harness.rs—attachsplits the arm:Missingreturnsnote_missing()and does not callcharge_loss;Failedstill does. A missing binary is not a child that might come back. A spawn that gets pastPATHclears the flag, so installing the CLI is picked up without a relaunch.settings.rs— the not-running row names the command and says ai-buddy does not bundle a Harness, instead of an errno.Deliberately not done:
harness_logininmain.rsis untouched. PR #661 deletes that function outright — Chat's Connect names the login command rather than spawning it — so the issue's "Chat Connect login" bullet is handled there, from the other direction. Adding ENOENT handling to a function being deleted would conflict and buy nothing.Which of the two argvs is missing
Launch::commandspawnsargv[0], so ENOENT is only ever about that. For claude, codex and piargv[0]isnpx; for grok, hermes, opencode and any Custom line it is the vendor binary. The sentence therefore namesargv[0]and neverlaunch.name: a missing launcher for codex reads "npxis not installed", which is true and claims nothing aboutcodex.The inverse — npx present,
codexabsent — produces no ENOENT from our spawn at all. npx starts, and the adapter's failure to findcodexsurfaces as an initialize error, which stays on the backoff ladder because a child genuinely did start. Nowhich codexpre-check was added to guess at it; that is a different failure.a_missing_launcher_is_not_a_missing_vendor_clipins this.How to verify
cargo test -p ai-buddy cargo clippy --workspace --all-targets -- -D warnings node --test tests/418 Rust tests pass, clippy clean, 108 node tests pass.
a_missing_binary_backs_off_instead_of_respawningpinned the behavior this issue reverses. It is renamed and rewritten, not deleted —a_missing_binary_says_so_instead_of_backing_off— and its doc comment records what it used to assert and why that was the bug. It keeps thesession.backoff(...)reads, since the ladder itself did not change.Guards were mutation-tested, and the failures observed rather than assumed:
Missingalso callscharge_lossErrorKind::NotFoundarm(os error 2)stringnote_missinguseslaunch.namenotargv[0]`codex`, wanted`npx``npx`in the rowA dying child still backs off. That half was verified separately with a real child that starts and exits before initialize:
spawn_wait_untilis still charged, and the existing death tests pass unchanged. A fix that dropped backoff for all failures would have been a regression.Notes
windows_jobarm was not compiled here —#[cfg(windows)], and this machine is aarch64-apple-darwin only, socargo checknever parses it. The edits are mechanical (two return types, onereturn Err(why)replacing aformat!, a deletedmap_err, fourio::Error::otherwraps) and were read carefully, but CI's Windows job is the first real check. Worth watching.not runningwhere Settings now says not-installed.ChatHarnesscarries nomissingfield, so closing that gap means touchingmain.rs— which fix(harness): Name the login rather than spawn it #661 owns. The stale parity claim insrc/chat-status.jswas corrected to say what is true and name the issue, rather than left asserting something false.Closes #659
— Claude Code agent, on @omesser's behalf.
🤖 Generated with Claude Code